/** 
 * Project Name : cloudlead-utils-async 
 * File Name : MyAsyncTask.java 
 * Package Name : com.cloudlead.utils.async 
 * Date : 2014年7月17日下午8:41:46 
 * Copyright (c) 2014, cloudlead.com.cn All Rights Reserved. 
 * 
 */
package com.cloudlead.utils.async;

/**
 *
 * @Description TODO(这里用一句话描述这个类的作用) 
 * 
 * @date 2014年7月17日 下午8:41:46 
 * @author 陆林(lulin@cloudlead-partners.com)
 * @version 2.0
 * @since 2.0
 */
public class MyAsyncTask implements AsyncTask<String> {

	private static final long serialVersionUID = -3563639066054256457L;
	
	private long count;
	private int seq;
	
	
	public MyAsyncTask(long count, int seq) {
		super();
		this.count = count;
		this.seq=seq;
	}

	/* 
	 * @see java.util.concurrent.Callable#call()
	 */
	@Override
	public String call() throws Exception {
		long i=0;
		while(i<count){
			System.out.println(this.getName()+" is doing");
			Thread.sleep(1000);
			if(5==i){
				throw new RuntimeException(this.getName()+" execute error.");
			}
			i++;
		}
		System.out.println(this.getName()+" is complete.");
		return this.getName()+" executed success";
	}

	/* 
	 * @see com.cloudlead.utils.async.AsyncTask#getName()
	 */
	public String getName() {
		return "Task ["+seq+"]";
	}



}
